#include<iostream>
#include<sstream>
#include<string.h>
#include<vector>


class String
{
public:
    int getnum();
    String();
    String(const char*);
    String(const String&);
    ~String();
    String &operator=(const String&);
    String &operator=(const char *);
    String & operator +=(const String &);
    String & operator +=(const char*);

    void print();


    char &operator[](std::size_t index);
    const char & operator[](std::size_t index) const;

    std::size_t size() const;
    const char* c_str() const;

    friend bool operator==(const String &,const String &);
    friend bool operator!=(const String&,const String &);

    friend bool operator<(const String &,const String &);
    friend bool operator>(const String &,const String &);
    friend bool operator<=(const String &,const String &);
    friend bool operator>=(const String &,const String &);
    friend String operator+(const String &,const String &);
    friend String operator+(const String &,const char *);
    friend String operator+(const char *,const String &);

    friend std::ostream &operator<<(std::ostream &os, const String &s );
    friend std::istream &operator>>(std::istream &is,  String &s );

private:
    char* malloc(const char*p=nullptr);
    char* malloc(size_t num);
    void addnum();
    void sub();
    void free();

private:
    char * _pstr=nullptr;
    static const int ksetconstnum;
};




